﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Base64Encoder
{
    class Base64Encoder
    {
        public static void EncodeToBase64(string inputFile, string outputFile)
        {
            FileStream reader = File.OpenRead(inputFile);
            using (reader)
            {
                BinaryReader binaryReader = new BinaryReader(reader);
                using (binaryReader)
                {
                    StreamWriter writer = new StreamWriter(outputFile);
                    using (writer)
                    {
                        byte[] readBytes = binaryReader.ReadBytes(40);
                        while (readBytes.Length != 0)
                        {
                            writer.WriteLine(System.Convert.ToBase64String(readBytes));
                            readBytes = binaryReader.ReadBytes(40);
                        }
                    }
                }
            }
        }
    }
}
